package com.puppet.building182.config;
import com.puppet.building182.handler.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class interceptorConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor logInterceptors;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //1.注册自己的拦截器到Springboot的拦截器队列
        InterceptorRegistration registration = registry.addInterceptor(logInterceptors);
       //2.配置拦截 拦截哪些请求，默认放行哪些请求(先全部拦截，再筛选不拦截请求)
        registration.addPathPatterns("/**");
        //2.2 排除掉 不拦截请求
        registration.excludePathPatterns(
                "/user/login",
                "/",
                "/**/*.html",
                "/**/*.js",
                "/**/*.css",
                "/**/*.ico",
                "/swagger-resources/**",
                "/webjars/**", "/v3/**", "/swagger-ui.html/**","/filter/**",
                "/test/**"

        );
    }
}
//页面跳转时使用